package edu.ynu.se.xiecheng.achitectureclass.nongye.controller;

import edu.ynu.se.xiecheng.achitectureclass.nongye.dao.SoilPHDAO;
import edu.ynu.se.xiecheng.achitectureclass.nongye.entity.SoilPH;
import edu.ynu.se.xiecheng.achitectureclass.nongye.service.SoilPHService;
import edu.ynu.se.xiecheng.achitectureclass.common.controller.LogicController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "土壤 PH 值管理")
@RestController
@RequestMapping("/soilph")
public class SoilPHController extends LogicController<SoilPHService, SoilPHDAO, SoilPH, Integer> {

    @Autowired
    public SoilPHController(SoilPHService soilPHService) {
        super(soilPHService);
    }

    @ApiOperation("根据ID获取土壤 PH 值信息")
    @GetMapping("/getsoilph")
    public SoilPH getSoilPHById(@RequestParam Integer id) {
        return getService().GET(id);
    }

    @ApiOperation("获取所有土壤 PH 值信息")
    @GetMapping("/getAllsoilph")
    public List<SoilPH> getAllSoilPH() {
        return getService().getAll();
    }

    @ApiOperation("创建土壤 PH 值记录")
    @PostMapping("/postsoilph")
    public SoilPH createSoilPH(@RequestBody SoilPH soilPH) {
        return getService().POST(soilPH);
    }

    @ApiOperation("更新土壤 PH 值记录")
    @PostMapping("/putsoilph")
    public SoilPH updateSoilPH(@RequestBody SoilPH soilPH) {
        return getService().PUT(soilPH);
    }

    @ApiOperation("删除土壤 PH 值记录")
    @PostMapping("/deletesoilph")
    public void deleteSoilPH(@RequestBody SoilPH soilPH) {
        getService().DELETE(soilPH);
    }

    @ApiOperation("通过ID删除土壤 PH 值记录")
    @GetMapping("/deleteByIdsoilph")
    public void deleteSoilPHById(@RequestParam Integer id) {
        getService().DELETE(id);
    }
}
